package com.sdhs.projectschedule.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.sdhs.projectschedule.domain.GcProgressPaymentCollectionTracking;
import com.sdhs.projectschedule.service.IGcProgressPaymentCollectionTrackingService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sdhs.common.annotation.Log;
import com.sdhs.common.core.controller.BaseController;
import com.sdhs.common.core.domain.AjaxResult;
import com.sdhs.common.enums.BusinessType;
import com.sdhs.common.utils.poi.ExcelUtil;
import com.sdhs.common.core.page.TableDataInfo;

/**
 * 项目进度控制--回款跟踪Controller
 *
 * @author andong
 * @date 2025-03-12
 */
@RestController
@RequestMapping("/progress/tracking")
public class GcProgressPaymentCollectionTrackingController extends BaseController
{
    @Autowired
    private IGcProgressPaymentCollectionTrackingService gcProgressPaymentCollectionTrackingService;

    /**
     * 查询项目进度控制--回款跟踪列表
     */
    @PreAuthorize("@ss.hasPermi('progress:tracking:list')")
    @GetMapping("/list")
    public TableDataInfo list(GcProgressPaymentCollectionTracking gcProgressPaymentCollectionTracking)
    {
        startPage();
        List<GcProgressPaymentCollectionTracking> list = gcProgressPaymentCollectionTrackingService.selectGcProgressPaymentCollectionTrackingList(gcProgressPaymentCollectionTracking);
        return getDataTable(list);
    }

    /**
     * 导出项目进度控制--回款跟踪列表
     */
    @PreAuthorize("@ss.hasPermi('progress:tracking:export')")
    @Log(title = "项目进度控制--回款跟踪", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GcProgressPaymentCollectionTracking gcProgressPaymentCollectionTracking)
    {
        List<GcProgressPaymentCollectionTracking> list = gcProgressPaymentCollectionTrackingService.selectGcProgressPaymentCollectionTrackingList(gcProgressPaymentCollectionTracking);
        ExcelUtil<GcProgressPaymentCollectionTracking> util = new ExcelUtil<GcProgressPaymentCollectionTracking>(GcProgressPaymentCollectionTracking.class);
        util.exportExcel(response, list, "项目进度控制--回款跟踪数据");
    }

    /**
     * 获取项目进度控制--回款跟踪详细信息
     */
    @PreAuthorize("@ss.hasPermi('progress:tracking:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(gcProgressPaymentCollectionTrackingService.selectGcProgressPaymentCollectionTrackingById(id));
    }

    /**
     * 获取项目进度控制--回款跟踪合同信息
     */
    @PreAuthorize("@ss.hasPermi('progress:tracking:query')")
    @GetMapping("/project/{id}")
    public TableDataInfo getProjectInfo(@PathVariable("id") Long id)
    {
        return getDataTable(gcProgressPaymentCollectionTrackingService.selectContractsByProjectId(id));
    }
    /**
     * 新增项目进度控制--回款跟踪
     */
    @PreAuthorize("@ss.hasPermi('progress:tracking:add')")
    @Log(title = "项目进度控制--回款跟踪", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GcProgressPaymentCollectionTracking gcProgressPaymentCollectionTracking)
    {
        return toAjax(gcProgressPaymentCollectionTrackingService.insertGcProgressPaymentCollectionTracking(gcProgressPaymentCollectionTracking));
    }

    /**
     * 修改项目进度控制--回款跟踪
     */
    @PreAuthorize("@ss.hasPermi('progress:tracking:edit')")
    @Log(title = "项目进度控制--回款跟踪", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GcProgressPaymentCollectionTracking gcProgressPaymentCollectionTracking)
    {
        return toAjax(gcProgressPaymentCollectionTrackingService.updateGcProgressPaymentCollectionTracking(gcProgressPaymentCollectionTracking));
    }

    /**
     * 删除项目进度控制--回款跟踪
     */
    @PreAuthorize("@ss.hasPermi('progress:tracking:remove')")
    @Log(title = "项目进度控制--回款跟踪", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(gcProgressPaymentCollectionTrackingService.deleteGcProgressPaymentCollectionTrackingByIds(ids));
    }
}
